<template>
	<view class="container">
		<phone-header
			:isrightHide=true
			title="搜索机型"
			titleColor="#fff"
			bgColor="#4CCCD5"
			titleFontWeight="none"
			@tapRight="tapRight"
			@tapLeft="tapLeft"
		></phone-header>
		<view class="search-content bg-shadow bg-fff">
			<view class="search-box">
				<view class="search-left iconfont icon-sousuo" @tap="searchFun"></view>
				<view class="search">
					<input type="text" focus v-model="changeVaule" @confirm="searchFun"/>
				</view>
				<view class="search-cancel iconfont icon-quxiao" @tap="cancelFun"></view>
			</view>
		</view>
		<view class="search-record">
			<view class="lately">最近搜索</view>
			<view class="record">
				<block v-for="(item, index) in searchAll" :key="index">
					<navigator>{{item}}</navigator>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	import phoneHeader from '../../components/phone-header/phone-header.vue'
	export default {
		onLoad() {
			const than = this
			uni.getStorage({
				key: 'searchAll_key',
				success(res) {
					than.searchAll = res.data
				}
			})
		},
		data() {
			return {
				changeVaule: '',
				searchAll: []
			}
		},
		methods: {
			cancelFun() {
				this.changeVaule = ''
			},
			searchFun() {
				if(this.changeVaule != '') {
					const than = this
					this.searchAll.push(this.changeVaule);
					uni.setStorage({
						key: 'searchAll_key',
						data: than.searchAll,
						success: function () {
							
						}
					})
					this.changeVaule = ''
				}
			}
		},
		components: {
			phoneHeader
		}
	}
</script>

<style lang="scss">
	@import '../../static/iconfont/iconfont.css';
	
	.search-content {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 82upx;
		.search-box {
			display: flex;
			align-items: center;
			width: 80%;
			height: 75%;
			line-height: 1.4;
			background: #f6f6f6;
			border-radius: 10upx;
			.iconfont {
				color: #cccccc;
				font-size: 48upx;
				padding: 0 12upx;
			}
			.search {
				flex: 1;
				padding-left: 20upx;
			}
		}
	}
	.search-record {
		padding: 40upx 48upx 0;
		.lately {
			font-size: 26upx;
			padding-bottom: 40upx;
		}
		.record {
			display: flex;
			flex-wrap: wrap;
			navigator{
				font-size: 24upx;
				border-radius: 10upx;
				background: #ffffff;
				box-shadow: 0 0.01rem 0.06rem 0 rgba(0, 0, 0, 0.1);
				margin-right: 20upx;
				margin-bottom: 32upx;
				padding: 12upx 20upx;
			}
		}
	}
</style>
